package com.cham.user.mapper;

import com.cham.user.dto.UserInfo;
import com.cham.user.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @author Howl-Xu
 * @version 1.0.0
 * @Description: 请描述一下这个类文件吧
 * @createTime 2020年03月14日 10:34:00
 */
public interface UserMapper {
//    @Insert("insert into sys_user(account,password,user_uuid) VALUES (#{account},#{password},#{uuid})")
//    void addUser(User user);

    @Select("select * from sys_user where account = #{account} and password = #{password}")
    User getUserByAccountAndPassword(@Param("account") String account, @Param("password") String password);

    @Select("select\n" +
            "\tsu.nick_name,\n" +
            "\tsu.sign,\n" +
            "\tsu.sex,\n" +
            "\tsu.account,\n" +
            "\tsu.birthday,\n" +
            "\tchi.img_base64\n" +
            "from\n" +
            "\tsys_user su left join \n" +
            "\tcham_head_img chi\n" +
            "\ton chi.user_uuid = su.user_uuid\n" +
            "where\n" +
            "\tsu.user_uuid = #{uuid}")
    UserInfo getUserInfoByUserUUID(@Param("uuid") String uuid);

    @Insert("insert into sys_user(account,password,user_uuid) VALUES (#{account},#{password},#{userUuid})")
    void register(User user);

    @Update("update sys_user set nick_name=#{nickName},sign=#{sign},sex=#{sex},birthday=#{birthday} where user_uuid = #{userUuid}")
    void updateUserInfo(UserInfo userInfo);

    @Update("update cham_head_img set img_base64=#{imgBase64} where user_uuid = #{userUuid}")
    void updateHeadImg(UserInfo userInfo);

//    @Select("select user_uuid from sys_user where account = #{account}")
//    String getUUIDByAccount(String account);

//    @Select("select * from sys_user where user_uuid = #{uuid}")
//    UserDTO getUserInfoByUUID(String uuid);
//
//    @Update("update sys_user set nick_name=#{nickName},sign=#{sign},sex=#{sex},birthday=#{birthday} where user_uuid = #{userUuid}")
//    void updateUserInfo(User user);
//
//    String getVideoPlayerLogo();
}
